/*
 *    Copyright © OpenAtom Foundation.
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *         http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package com.inspur.edp.bef.spi.action.assembler;

import com.inspur.edp.bef.api.action.assembler.IMgrActionAssembler;
import com.inspur.edp.bef.api.be.IBEManagerContext;

/** 自定义管理动作组装器的默认实现，继承自IMgrActionAssembler接口 */
public class MgrActionAssembler implements IMgrActionAssembler {
  /**
   * 新实例初始化MgrActionAssembler具有给定的BE管理器上下文
   *
   * @param beManagerContext BE管理类上下文
   */
  public MgrActionAssembler(IBEManagerContext beManagerContext) {
    this.context = beManagerContext;
  }

  private IBEManagerContext context;

  /** 获取BE管理类上下文 */
  protected final IBEManagerContext getContext() {
    return context;
  }

  /** 自定义管理动作执行前记录日志时的虚扩展方法 */
  public void logBeforeExecute() {}

  /** 自定义管理动作执行前的虚扩展方法 */
  public void beforeExecute() {}

  /** 自定义管理动作执行后的虚扩展方法 */
  public void afterExecute() {}

  /** 自定义管理动作执行后记录日志时的虚扩展方法 */
  public void logAfterExecute() {}

  /**
   * 自定义动作执行抛异常时的虚扩展方法
   *
   * @param e 异常信息
   * @return
   */
  public boolean handleException(RuntimeException e) {
    return true;
  }

  /** 自定义管理动作执行失败时记录日志时的虚扩展方法 */
  public void logAfterExecuteFail() {}

  /** 执行权限判断 */
  public void demandFuncPermission() {}
}
